package com.twu.biblioteca;

import java.util.Comparator;

//for Comparison by books name
class BookComparatorByBookName implements Comparator<Book>
{
    public int compare(Book book1, Book book2) {
        return book1.bookName.compareToIgnoreCase(book2.bookName);
    }
}

//for Comparison by author name
class BookComparatorByAuthorName implements Comparator<Book>
{
    public int compare(Book book1, Book book2) {
        return book1.authorName.compareToIgnoreCase(book2.authorName);
    }
}

//for Comparison by ISBN
class BookComparatorByISBN implements Comparator<Book>
{
    public int compare(Book book1, Book book2) {
        long difference=book1.ISBN-book2.ISBN;
        if(difference>0)
            return 1;
        else if(difference<0)
            return -1;
        else
            return 0;
    }
}
public class Book {

    String bookName;
    String authorName;
    long ISBN;
    int availableCopies;

    public Book()
    {
        //Initialisation of variables
        bookName= " ";
        authorName= " ";
        ISBN=0;
        availableCopies=0;
    }

    public Book(String bookName,String authorName,long ISBN,int availableCopies)
    {
        //Assigning values to class variables
        this.bookName=bookName;
        this.authorName=authorName;
        this.ISBN=ISBN;
        this.availableCopies=availableCopies;
    }
}
